# Maintainer: Thore Bödecker <foxxx0@archlinux.org>
# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Christoph Scholz <christoph.scholz@gmail.com>

_gemname='sys-proctable'
pkgname="ruby-${_gemname}"
pkgver=1.3.0
pkgrel=1
pkgdesc='An interface for providing process table information'
arch=('any')
url='https://github.com/djberg96/sys-proctable'
license=('Apache')
depends=('ruby' 'ruby-ffi')
makedepends=('ruby-rake' 'ruby-rdoc' 'ruby-rake-compiler' 'ruby-yard' 'ruby-rspec' 'ruby-bundler'
             'ruby-rubocop-rake')
checkdepends=('ruby-test-unit')
options=('!emptydirs')
source=("${url}/archive/${_gemname}-${pkgver}.tar.gz")
sha512sums=('962581803191e944cb6a6ab1601bab2ad004bd8479e4fb1f3eda622afefe66727656521845914ad5d34385780ad12bf65500ee621854b2bc08b24144392bdc99')

prepare() {
  cd "${srcdir}/${_gemname}-${_gemname}-${pkgver}"

  # we won't sign our output gemfile (i.e. we won't upload to rubygems)
  sed -i '/spec.signing_key/d' Rakefile

  # we're running in a limited chroot and won't reach the default 10 procs for `top` output
  # just disable this test and move on
  sed -i '/described_class.top.size/d' spec/sys_top_spec.rb

  # the date field in the gemspec is useless and makes the package non-reproducible
  sed -i '/s.date/d' sys-proctable.gemspec
}

build() {
  cd "${srcdir}/${_gemname}-${_gemname}-${pkgver}"
  rake gem:create
}

check() {
  cd "${srcdir}/${_gemname}-${_gemname}-${pkgver}"
  rake spec
}

package() {
  cd "${srcdir}/${_gemname}-${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "${pkgdir}/${_gemdir}" \
    --bindir "${pkgdir}/usr/bin"  \
    "${_gemname}-${pkgver}.gem"

  rm -rf "${pkgdir}/${_gemdir}/cache"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
  install -Dm 644 README.md examples/example_ps.rb CHANGES.md -t "${pkgdir}/usr/share/doc/${pkgname}/"
}

# vim: ts=2 sw=2 et:
